//
//  ZMLabel.swift
//  OnlineClassRoom
//
//  Created by Rowling on 2020/5/13.
//  Copyright © 2020 智蚂优服. All rights reserved.
//

import UIKit

class ZMLabel: UILabel {

    /// 内边距
    var zm_edgeInsets: UIEdgeInsets = .zero
    
    override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
        var rect = super.textRect(forBounds: bounds.inset(by: zm_edgeInsets), limitedToNumberOfLines: numberOfLines)
        rect.origin.x -= zm_edgeInsets.left
        rect.origin.y -= zm_edgeInsets.top
        rect.size.width += (zm_edgeInsets.left + zm_edgeInsets.right)
        rect.size.height += (zm_edgeInsets.top + zm_edgeInsets.bottom)
        return rect
    }
    
    override func drawText(in rect: CGRect) {
        super.drawText(in: rect.inset(by: zm_edgeInsets))
    }
    
}
